package Task2;

import java.util.Scanner;
//排序子序列
public class Main {
    public static void main(String[] args) {
        Scanner  scanner = new Scanner(System.in);
        while(scanner.hasNextInt()){
            int n = scanner.nextInt();
            int[] elem = new int[n + 1];
            for (int i = 0; i < elem.length - 1; i++) {
                elem[i] = scanner.nextInt();
            }
            int count = 0;
            int i = 0;
           while (i < elem.length - 1){
               if(elem[i] < elem[i+1]){
                   while (i < elem.length -1 && elem[i] < elem[i+1]){
                       i++;
                   }
                   count++;
                   i++;
               } else if (elem[i] > elem[i+1]) {
                   while (i < elem.length -1 && elem[i] > elem[i+1]){
                       i++;
                   }
                   count++;
                   i++;
               }else{
                   i++;
               }
           }
            System.out.println(count);
        }
    }
}

